package com.openbravo.data.gui;

import com.openbravo.basic.BasicException;
import com.openbravo.data.loader.Vectorer;
import com.openbravo.data.user.Finder;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class FindInfo
  implements Finder
{
  public static final int MATCH_STARTFIELD = 0;
  public static final int MATCH_WHOLEFIELD = 1;
  public static final int MATCH_ANYPARTFIELD = 2;
  public static final int MATCH_REGEXP = 3;
  private String m_sTextCompare;
  private Pattern m_TextPattern;
  private String m_sText;
  private int m_iField;
  private int m_iMatch;
  private boolean m_bMatchCase;
  private Vectorer m_vec;

  public FindInfo(Vectorer paramVectorer, String paramString, int paramInt1, boolean paramBoolean, int paramInt2)
  {
    this.m_vec = paramVectorer;
    this.m_sText = paramString;
    this.m_iField = paramInt1;
    this.m_bMatchCase = paramBoolean;
    this.m_iMatch = paramInt2;
    if (paramInt2 == 3)
      this.m_TextPattern = (this.m_bMatchCase ? Pattern.compile(this.m_sText) : Pattern.compile(this.m_sText, 2));
    else
      this.m_sTextCompare = (this.m_bMatchCase ? this.m_sText : this.m_sText.toUpperCase());
  }

  public FindInfo(Vectorer paramVectorer)
  {
    this(paramVectorer, "", 0, true, 2);
  }

  public Vectorer getVectorer()
  {
    return this.m_vec;
  }

  public String getText()
  {
    return this.m_sText;
  }

  public int getField()
  {
    return this.m_iField;
  }

  public boolean isMatchCase()
  {
    return this.m_bMatchCase;
  }

  public int getMatch()
  {
    return this.m_iMatch;
  }

  public boolean match(Object paramObject)
    throws BasicException
  {
    String[] arrayOfString = this.m_vec.getValues(paramObject);
    String str = this.m_bMatchCase ? arrayOfString[this.m_iField] : arrayOfString[this.m_iField].toUpperCase();
    switch (this.m_iMatch)
    {
    case 0:
      return str.startsWith(this.m_sTextCompare);
    case 1:
      return str.equals(this.m_sTextCompare);
    case 2:
      return str.indexOf(this.m_sTextCompare) >= 0;
    case 3:
      return this.m_TextPattern.matcher(str).matches();
    }
    return false;
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.data.gui.FindInfo
 * JD-Core Version:    0.6.0
 */